import turtle as t
sides = int(t.numinput("边数",
                       "嵌套螺旋线有几条边？（2~5）",
                       4,2,5))
colors = "red,orange,blue,green,purple".split(',')
t.tracer(10)
t.pencolor('red')
for m in range(100):
    t.forward(m*4)
    position = t.position()
    heading = t.heading()
    t.pendown()
    for n in range(int(m/2)):
        t.pencolor(colors[n%sides])
        t.forward(2*n)
        t.right(360/sides - 2)
    t.penup()
    t.setx(position[0])
    t.sety(position[1])
    t.setheading(heading)
    t.right(360/sides + 2)
t.mainloop()